﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Base;
using Solely;
using WebBasicInfo;
using UserInfo;
using VipGrade;
using Message;
using Product;

public partial class Member_Index : nspBase.MemberBasePge
{
    public string strGrade;
    public DataTable expoTab = new DataTable();
    public DataTable supplyTab = new DataTable();
    public string remindAllCount = "0";
    public string noreadmesCount = "0";
    public string nosupplyCount = "0";
    public string expiredsupplyCount = "0";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (CheckCookies())
            {
                if (!IsPostBack)
                {
                    Bind();
                }
            }
            else
            {
                Response.Redirect("~/login/login.aspx");
            }
        }
        catch(Exception ex)
        {
            Response.Write(ex.Message);
        }

    }

    /// <summary>
    /// 会员中心首页
    /// </summary>
    private void Bind()
    {
        ExpoNewsBind();
        SupplyNewsBind();
        BasicBind();
    }
    /// <summary>
    /// 会员身份及网站咨询热线信息
    /// </summary>
    private void BasicBind()
    {
        
       DataTable noreadMes = new RMessage().GetListByUserID(int.Parse(GetCookie("UserID").ToString()), 0);
       noreadmesCount = noreadMes.Rows.Count.ToString();
       DataTable noaduitSuplly = new RSupply().GetListByUserID(" UserID=" + GetCookie("UserID") + " and Verify=0 ");
       nosupplyCount = noaduitSuplly.Rows.Count.ToString();
       DataTable expiredSupply = new RSupply().GetListByUserID(" UserID=" + GetCookie("UserID") + " and (datediff(hh,C_Supply.EndDate,getdate())>0)  ");
       expiredsupplyCount = expiredSupply.Rows.Count.ToString();
       remindAllCount = (noreadMes.Rows.Count + noaduitSuplly.Rows.Count + expiredSupply.Rows.Count).ToString();
    }
    /// <summary>
    ///展会资讯 
    /// </summary>
    private void ExpoNewsBind()
    {
        int Pageindex = 1;
        int pageSize = 5;
        string strWhere = " UserID= " + GetCookie("UserID");
        string table = "W_Expo left JOIN W_ExpoType on W_Expo.TypeID = W_ExpoType.ID";
        string select = " W_Expo.*, W_ExpoType.Type";
        expoTab = PageList.GetDataTable(strWhere, table, 1, "W_Expo.AddDate", select, pageSize, Pageindex, 0);
    }
    private void SupplyNewsBind()
    {
        int Pageindex = 1;
        int pageSize = 5;
        string strWhere = " UserID= " + GetCookie("UserID");
        string table = "C_Supply ";
        string select = " *";
        supplyTab = PageList.GetDataTable(strWhere, table, 1, "AddDate", select, pageSize, Pageindex, 0);
    }
}
